
#ifndef FIBER_ENV_SOCKET_H_
#define FIBER_ENV_SOCKET_H_

#include <sys/socket.h>

namespace fasmio { namespace fiber_env {

class ITCPSocket
{
public:
    virtual ~ITCPSocket() {};

public:
    virtual bool Bind(const char *addr, unsigned short port, bool reuse_addr) = 0;

    virtual bool Listen(int backlog) = 0;

    virtual ITCPSocket* Accept(char *addr, int addr_len) = 0;

    virtual bool Connect(const char *addr, unsigned short port) = 0;

    virtual long Send(const void* buff, unsigned long size) = 0;

    virtual long Receive(void* buff, unsigned long size) = 0;

    virtual long SendAll(const void* buff, unsigned long size) = 0;

    virtual long ReceiveAll(void* buff, unsigned long size) = 0;

    virtual bool Shutdown(int how) = 0;

    virtual void Close() = 0;

    virtual int GetLastError() = 0;
};

}}  // namespace fasmio::fiber_env

#endif  // FIBER_ENV_SOCKET_H_

